var app=sm("do_App");
var page=sm("do_Page");
var nf = sm("do_Notification");

var do_back=ui("do_back");
var do_SegmentView_tabs = ui("do_SegmentView_tabs");
var do_SlideView_news = ui("do_SlideView_news");
page.on("back",function(){	
	app.closePage();
});
do_back.on("touch",function(){
	app.closePage();
});
var jsonTabs = [     
	{
		id : "0",
	    title : "未处理",
	    selected : "1",
	    template : 0
	},
	{
		id : "1",
	    title : "已处理",
	    selected : "0",
	    template : 0
	}
];
var jsonSlides = JSON.parse(JSON.stringify(jsonTabs));
var listdataTabs = mm("do_ListData");
listdataTabs.addData(jsonTabs);
var listdataSlides = mm("do_ListData");
listdataSlides.addData(jsonSlides);
page.on("selectOneTab", function(data){
	var _selectedIndex=-1;
	for(var i=0; i<jsonTabs.length;i++){
		if (jsonTabs[i].title == data.title){
			_selectedIndex =i;
			listdataTabs.updateOne(i, 
				{
					id:jsonTabs[i].id,
				    title : jsonTabs[i].title,
				    selected : "1",
				    template : jsonTabs[i].template
				}
			);
		}
		else{
			listdataTabs.updateOne(i, 
				{
					id:jsonTabs[i].id,
				    title : jsonTabs[i].title,
				    selected : "0",
				    template : jsonTabs[i].template
				}
			);
		}
	}
	do_SegmentView_tabs.refreshItems();
	if (_selectedIndex >=0)	do_SegmentView_tabs.index = _selectedIndex;	
});
page.on("loaded", function(){
	var nowdate=new Date();
	var olddate=nowdate.getTime();
	app.fire("tologin",{times:olddate,pagesize:2});
	do_SegmentView_tabs.bindItems(listdataTabs);
	do_SlideView_news.bindItems(listdataSlides);
});
do_SegmentView_tabs.on("indexChanged", function(index) {   
	do_SlideView_news.index = index;
});
 
do_SlideView_news.on("indexChanged", function(index) {
	page.fire("selectOneTab", {title:jsonTabs[index].title});
});

